package cn.xeblog.plugin.util;

import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.extensions.PluginId;

/**
 * idea工具类
 *
 * @author anlingyi
 * @date 2021/9/4 9:26 上午
 */
public class IdeaUtils {

  /**
   * idea标识id
   */
  private final static String ID = "cn.xeblog.xechat.plugin";

  /**
   * 获取插件版本
   *
   * @return 插件描述
   */
  public static String getPluginVersion() {
    IdeaPluginDescriptor pluginDescriptor = PluginManagerCore.getPlugin(PluginId.getId(ID));
    return pluginDescriptor == null ? "???" : pluginDescriptor.getVersion();
  }

}
